/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package src.report.loan;

import java.util.List;
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;
import src.domain.loan.Loansimulate;

/**
 *
 * @author Yusup Jauhari Shandi <in.visi>
 */
public class RptLoansimDS implements JRDataSource{
    private int index = -1;
    
    List<Loansimulate> loansimulates;
    
    public RptLoansimDS(List<Loansimulate> sim) {
        super();
        this.loansimulates = sim;
    }
    
    @Override
    public boolean next() throws JRException {
        index++;
        return (index < loansimulates.size());
    }

    @Override
    public Object getFieldValue(JRField jrf) throws JRException {
        Object value = null;

	String fieldName = jrf.getName();
        switch (fieldName) {
            case "paymentIdx": value = loansimulates.get(index).getPaymentIdx(); break;
            case "date": value = loansimulates.get(index).getDate(); break;
            case "amount": value = loansimulates.get(index).getAmount(); break;
            case "interest": value = loansimulates.get(index).getInterest(); break;
            case "total": value = loansimulates.get(index).getTotal(); break;
            case "outstanding": value = loansimulates.get(index).getOutstanding(); break;
            case "description": value = loansimulates.get(index).getDescription(); break;
        }
	return value;
    }
    
}
